﻿namespace MicroCloud.Systems
{
    public partial class DictService : IDictService
    {
        /// <summary>
        /// 初始化一个文件存储管理器（<see cref="DictService"/>）的新实例
        /// </summary>
        /// <param name="provider">服务提供程序</param>
        public DictService(IServiceProvider provider)
        {
            ServiceProvider = provider;
        }

        #region 基础属性
        /// <summary>
        /// 获取 服务提供者对象
        /// </summary>
        protected IServiceProvider ServiceProvider { get; }

        /// <summary>
        /// 获取 事件总线
        /// </summary>
        protected IEventBus EventBus => ServiceProvider.GetService<IEventBus>();

        /// <summary>
        /// 获取 日志对象
        /// </summary>
        protected ILogger Logger => ServiceProvider.GetLogger(GetType());

        #endregion

        /// <summary>
        /// 获取 字典仓储模型
        /// </summary>
        protected IRepository<Dict, Guid> DictRepository => ServiceProvider.GetService<IRepository<Dict, Guid>>();

        /// <summary>
        /// 获取 字典项仓储模型
        /// </summary>
        protected IRepository<DictEntry, Guid> DictEntryRepository => ServiceProvider.GetService<IRepository<DictEntry, Guid>>();

    }
}